package com.tongji.showroom.view
{
	import com.tongji.showroom.events.GetUserSceneEvent;
	import com.tongji.showroom.model.UserModel;
	
	import flash.net.SharedObject;
	
	import mx.controls.Text;
	
	import org.robotlegs.mvcs.Mediator;
	
	import spark.events.TextOperationEvent;
	
	public class FirstStepCompMediator extends Mediator
	{
		[Inject]
		public var model:UserModel;
		
		[Inject]
		public var view:FirstStepComp;
		
		override public function onRegister():void
		{
			eventMap.mapListener(view.user, TextOperationEvent.CHANGE, setUser);
		}
		
		private function setUser(event:TextOperationEvent):void
		{
			model.userID = Number(view.user.text);
			var cookie:SharedObject = SharedObject.getLocal("cookie","/");
			cookie.data.userID = model.userID;
			cookie.flush();
			dispatch(new GetUserSceneEvent(GetUserSceneEvent.GET_USER_SCENE, model.userID, 1, 1));
		}
	}
}